package com.mediatek.factorymode.simcard;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.telephony.TelephonyManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import com.mediatek.factorymode.R;
import com.mediatek.factorymode.Utils;
import com.android.internal.telephony.TelephonyProperties;
import android.os.SystemProperties;

public class SimCard extends Activity
{
  private boolean SimState = false;
  private boolean Sim1State = false;
  private boolean Sim2State = false;
  private String mSimStatus;
  SharedPreferences mSp;
  //private int absent = TelephonyManager.SIM_STATE_ABSENT;

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.mSp = getSharedPreferences("FactoryMode", 0);
	TelephonyManager manager = TelephonyManager.getDefault();
	Sim1State=manager.hasIccCard(SubscriptionManager.getSlotId(1));
	Sim2State=manager.hasIccCard(SubscriptionManager.getSlotId(2));
			
    StringBuilder localStringBuilder1 = new StringBuilder();

    if(this.Sim1State){
        localStringBuilder1.append(getString(R.string.sim1_info_ok)).append("\n");
    }else{
        localStringBuilder1.append(getString(R.string.sim1_info_failed)).append("\n");
    }

    if(this.Sim2State){
        localStringBuilder1.append(getString(R.string.sim2_info_ok)).append("\n");
    }else{
        localStringBuilder1.append(getString(R.string.sim2_info_failed)).append("\n");
    }

    this.mSimStatus = localStringBuilder1.toString();
    new AlertDialog.Builder(this).setTitle(R.string.SimCard)
    .setMessage(this.mSimStatus)
    .setPositiveButton(R.string.Success, new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            Utils.SetPreferences(SimCard.this, SimCard.this.mSp, R.string.sim_name, "success");
            SimCard.this.finish();
        }
    })
    .setNegativeButton(R.string.Failed, new DialogInterface.OnClickListener(){
        public void onClick(DialogInterface dialog, int which) {
            // TODO Auto-generated method stub
            Utils.SetPreferences(SimCard.this, SimCard.this.mSp, R.string.sim_name, "failed");
            SimCard.this.finish();
        }
    })
    .create()
    .show();
  }
}

